1. Field of the Invention
The present invention relates to a method and related device for storing digital television program data, and more particularly, to a method and related device for converting a transport stream carrying digital television program data to a file.
2. Description of the Prior Art
With the popularity of digital TV, demands on set-top boxes (STBs) or other digital TV reception devices are increasing. Generally, a digital TV reception device is mainly used for performing operations like filtering, demodulation, demultiplexing, decompression, etc. on received digital TV signals, so as to rebuild digital TV programs broadcasted by TV stations for the users.
As well-known in the art, digital TV data is carried by a transport stream (TS) defined in an MPEG-2 video compression standard. Please refer to FIG. 1, which illustrates how a conventional transport stream is formed. According to definitions of the MPEG-2 standard, original audio and/or video digital signals are respectively encoded by MPEG-2 encoders to form video and/or audio elementary streams (ES). In addition to the audio and video signals, some sorts of data, such as teletext information, subtitles or other private data that is necessary for digital TV programs, also forms a data elementary stream. However, these elementary streams cannot be transmitted or stored directly, but have to be forwarded into a packetizer for being packetized to form Packetized Elementary Streams (PES) first. In other words, the packetized elementary streams are formed by segmenting continuous elementary streams into packets for facilitating transmission, wherein the packets in the packetized elementary streams are utilized for carrying access units of the elementary streams, which is also defined in the MPEG-2 standard and not narrated herein.
Finally, the packetized elementary streams (including a video PES and an audio PES) are multiplexed by a multiplexer into a program stream (PS) or a transport stream (TS) for being stored or transmitted. The PS and TS formats are both defined for transmission in the MPEG-2 standard. However, since the size of the PS packet is not fixed, the PS format is preferred for use in a storage medium where errors rarely occur, such as DVD discs. Conversely, the TS format utilizes fixed-size packets, which not only makes it much easier for hardware to process the data, but is also more suitable for performing error correction. Therefore, the TS format is mainly utilized for transmission where errors easily occur, such as IEEE 1394 protocol or digital video broadcasting (DVB).
Each TS packet occupies 188 bytes, wherein the first 4 bytes are a header and the payload after the header is data of a PES packet. Each header of the TS packet has a field for storing a packet identifier (PID) and clock information. The PID is utilized for identifying packets that belong to the same data stream, so that a digital TV reception device such as a set-top box can retrieve a PES with the same PID from a TS accordingly. For example, a TS usually includes at least an audio PES and a video PES, in which packets of the audio PES can be identified by a specific audio PID, and similarly, packets of the video PES can be identified by a specific video PID.
Briefly speaking, the ES, which can be an audio ES or a video ES, is program data encoded after being compressed by the MPEG-2 standard. The PES is formed of packets by segmenting a continuous ES data stream and inserting packet headers. The TS is practically a stream format for transmission in the MPEG-2 standard, and includes a series of TS packets composed from various TV programs. The PS is also a stream format for transmission in the MPEG-2 standard, but only includes packets composed from a single TV program.
When the digital TV signal transmitted in the TS format is received by the digital TV reception device, recording of TV programs carried in the TS can be roughly divided into two kinds. One is to record the received digital TV signal in the TS format directly, on a hard disc for example. However, the TS recorded in the hard disc is hard to modify or manage, and data quantity of the TS is quite large (since there exists various TV programs in the TS), so that finite capacity of the hard disc becomes an issue of this method. The other way is performing filtering and MPEG-2 decoding operations for the received TS to retrieve desired TV program data. Then, the retrieved TV program data is further encoded into the PS format, so as to reduce the size of stored data. However, a set of MPEG-2 decoding/encoding (codec) systems needs to be implemented, resulting in the increase in cost and complexity of the whole system.
In addition, a method of converting a TS to a PS is disclosed in US patent publication No. US20060215707, entitled “System and Method for Stream Format Conversion,” in which corresponding PES or ES are retrieved from the TS and are multiplexed to form a PS directly, so as to avoid the use of the MPEG-2 codec system. Although the codec system is eliminated, the TV program data being stored is limited to the PS format, so format conversion has to be performed when the TV program data is transferred for play on other devices, which causes significant inconvenience of use.